import 'package:get/get.dart';
import 'package:safetymonitor/app/components/personnel_department_tree/personnel_department_tree_view.dart';
import 'package:safetymonitor/app/components/select_page/schedule_config_selection/schedule_config_selection_page.dart';
import 'package:safetymonitor/app/components/select_page/system_user_people_selection/system_user_people_selection_page.dart';
import 'package:safetymonitor/app/components/select_page/yh_system_user_people_selection/page.dart';
import 'package:safetymonitor/modules/auth/login/view.dart';
import 'package:safetymonitor/modules/auth/splash/splash_view.dart';
import 'package:safetymonitor/modules/home/alarm_warning/no_completed/otherDispose/view.dart';
import 'package:safetymonitor/modules/home/alarm_warning/no_completed/redAndOrangeDispose/view.dart';
import 'package:safetymonitor/modules/home/alarm_warning/view.dart';
import 'package:safetymonitor/modules/home/device_manger/device_details.dart';
import 'package:safetymonitor/modules/home/device_manger/device_manger.dart';
import 'package:safetymonitor/modules/home/device_manger/maintain_logs/add_update_maintain_logs/view.dart';
import 'package:safetymonitor/modules/home/device_manger/maintain_logs/view.dart';
import 'package:safetymonitor/modules/home/enterprise/a_enterprise.dart';
import 'package:safetymonitor/modules/home/home_page/duty_manager/duty/start_scheduling/select_people/select_people_view.dart';
import 'package:safetymonitor/modules/home/home_page/duty_manager/duty/start_scheduling/view.dart';
import 'package:safetymonitor/modules/home/home_page/duty_manager/duty/start_the_shift/view.dart';
import 'package:safetymonitor/modules/home/home_page/duty_manager/duty_manager_view.dart';
import 'package:safetymonitor/modules/home/home_page/monitor/new_personnel_monitoring/detail/detail_view.dart';
import 'package:safetymonitor/modules/home/home_page/monitor/personnel_monitoring/dynamic_trajectory/dynamic_trajectory_view.dart';
import 'package:safetymonitor/modules/home/home_page/monitor/today/today_view.dart';
import 'package:safetymonitor/modules/home/index_rating/view.dart';
import 'package:safetymonitor/modules/home/knowledge_base/detail/view.dart';
import 'package:safetymonitor/modules/home/knowledge_base/view.dart';
import 'package:safetymonitor/modules/home/maintenance/view.dart';
import 'package:safetymonitor/modules/home/message_board/board_details.dart';
import 'package:safetymonitor/modules/home/message_board/message_board.dart';
import 'package:safetymonitor/modules/home/message_board/notice_board_release/view.dart';
import 'package:safetymonitor/modules/home/new_alarm_warning_page/completed/detail/view.dart';
import 'package:safetymonitor/modules/home/new_alarm_warning_page/no_completed/detail/view.dart';
import 'package:safetymonitor/modules/home/new_alarm_warning_page/view.dart';
import 'package:safetymonitor/modules/home/risk_commitment/view.dart';
import 'package:safetymonitor/modules/home/snap_shot/select_people/select_people_view.dart';
import 'package:safetymonitor/modules/home/snap_shot/snap_shot_history/snap_shot_history_view.dart';
import 'package:safetymonitor/modules/home/snap_shot/snap_shot_view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/add_hazard/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/completed/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/no_distributed/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/no_rectification/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/pending_acceptance/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/no_completed/under_rectification/view.dart';
import 'package:safetymonitor/modules/home/snap_shot_danger/view.dart';
import 'package:safetymonitor/modules/home/statistical_analysis/on_offline_device/view.dart';
import 'package:safetymonitor/modules/home/statistical_analysis/view.dart';
import 'package:safetymonitor/modules/home/user/help/help_view.dart';
import 'package:safetymonitor/modules/home/user/scan_login/scan_login_view.dart';
import 'package:safetymonitor/modules/home/user/settings/permission.dart';
import 'package:safetymonitor/modules/home/user/settings/setting_list.dart';
import 'package:safetymonitor/modules/home/user/settings/setting_password/setting_password_view.dart';
import 'package:safetymonitor/modules/home/user/user_info/common/common_view.dart';
import 'package:safetymonitor/modules/home/user/user_info/user_info_view.dart';
import 'package:safetymonitor/modules/home/user/version_info/version_update_view.dart';
import 'package:safetymonitor/modules/home/video_monitor/video_monitor.dart';
import 'package:safetymonitor/modules/home/view.dart';
import 'package:safetymonitor/modules/home/warning_disposal/disposal_details/disposal_details_view.dart';
import 'package:safetymonitor/modules/home/warning_disposal/warning_disposal_view.dart';
import 'package:safetymonitor/router/app_auth_middleware.dart';

part 'app_routes.dart';

abstract class AppPages {
  AppPages._();

  /// 入口
  static const String initial = Routes.splash;

  static final routes = _generateRoutes();

  static List<GetPage> _generateRoutes() {
    final result = <GetPage>[];
    result.addAll(_generateAuthRoutes());
    result.addAll(_generateHomeRoutes());
    result.addAll(_generatePersonalRoutes());
    result.addAll(_generateOneEnterpriseOneFileRoutes());
    return result;
  }

  /// 构建页面
  ///
  /// [needAuth] 表示是否需要登录认证才可访问
  static GetPage generatePage({
    required String name,
    required GetPageBuilder page,
    bool needAuth = true,
    String? title,
    Transition? transition,
    List<GetMiddleware>? middlewares,
    Bindings? binding,
  }) {
    final middlewareList = <GetMiddleware>[];

    if (middlewares?.isNotEmpty == true) {
      middlewareList.addAll(middlewareList);
    }

    if (needAuth) {
      middlewareList.add(AppAuthMiddleWare());
    }

    return GetPage(
      name: name,
      page: page,
      title: title,
      // 路由动画
      transition: transition ?? Transition.native,
      middlewares: middlewareList,
      binding: binding,
    );
  }

  /// auth相关
  static List<GetPage> _generateAuthRoutes() {
    return [
      generatePage(
        name: Routes.authLogin,
        page: LoginPage.new,
        needAuth: false,
      ),
      generatePage(
        name: Routes.splash,
        page: SplashPage.new,
        needAuth: false,
      ),
      generatePage(
        name: Routes.selectPeople,
        page: SelectPeoplePage.new,
        needAuth: false,
      ),
       generatePage(
        name: Routes.dutySelectPeople,
        page: DutySelectPeoplePage.new,
        needAuth: false,
      ),
    ];
  }

  /// 首页
  static List<GetPage> _generateHomeRoutes() {
    return [
      generatePage(
        name: Routes.home,
        page: HomePage.new,
      ),
      generatePage(
        name: Routes.knowledgeBase,
        page: KnowledgeBasePage.new,
      ),
      generatePage(
        name: Routes.knowledgeBaseDetail,
        page: KnowledgeBaseDetailPage.new,
      ),
      generatePage(
        name: Routes.warningDisposal,
        page: WarningDisposalPage.new,
      ),
        generatePage(
        name: Routes.alarmWarningPage,
        page: AlarmWarningPage.new,
      ),
       generatePage(
        name: Routes.newAlarmWarningPage,
        page: NewAlarmWarningPagePage.new,
      ),
      generatePage(
        name: Routes.videoMonitoring,
        page: VideoMonitor.new,
      ),
      generatePage(
        name: Routes.deviceManagement,
        page: DeviceManger.new,
      ),
      generatePage(
        name: Routes.maintainLogs,
        page: MaintainLogsPage.new,
      ),
      generatePage(
        name: Routes.addUpdateMaintainLogs,
        page: AddUpdateMaintainLogsPage.new,
      ),
      generatePage(
        name: Routes.snapShot,
        page: SnapShotPage.new,
      ),
      generatePage(
        name: Routes.snapShotDanger,
        page: SnapShotDangerPage.new,
      ),
      generatePage(
        name: Routes.addHazardPage,
        page: AddHazardPage.new,
      ),
      generatePage(
        name: Routes.noDistributedStatPage,
        page: NoDistributedStatePage.new,
      ),
      generatePage(
        name: Routes.noRectificationStatPage,
        page: NoRectificationStatePage.new,
      ),
       generatePage(
        name: Routes.underRectificationStatPage,
        page: UnderRectificationStatePage.new,
      ),
       generatePage(
        name: Routes.pendingAcceptanceStatPage,
        page: PendingAcceptanceStatePage.new,
      ),
       generatePage(
        name: Routes.completedStatePage,
        page: CompletedStatePage.new,
      ),
      generatePage(
        name: Routes.snapShotHistory,
        page: SnapShotHistoryPage.new,
      ),
      generatePage(
        name: Routes.disposalDetails,
        page: DisposalDetailsPage.new,
      ),
      generatePage(
        name: Routes.redDisposePage,
        page: RedDisposePage.new,
      ),
      generatePage(
        name: Routes.completedDetailPage,
        page: CompletedDetailPage.new,
      ),
      generatePage(
        name: Routes.otherDisposePage,
        page: OtherDisposePage.new,
      ),    generatePage(
        name: Routes.alarmDetailPage,
        page:AlarmDetailPage.new,
      ),

    generatePage(
        name: Routes.deviceManagementDetail,
        page: DeviceDetails.new,
      ),
      generatePage(
        name: Routes.dutyManagement,
        page: DutyManagerPage.new,
      ),
      generatePage(
        name: Routes.noticeBoard,
        page: MessageBoard.new,
      ),
      generatePage(
        name: Routes.noticeBoardDetail,
        page: BoardDetails.new,
      ),
      generatePage(
        name: Routes.noticeBoardReleasePage,
        page: NoticeBoardReleasePage.new,
      ),
      generatePage(
        name: Routes.dynamicTrajectoryPage,
        page: DynamicTrajectoryPage.new,
      ),
      generatePage(
        name: Routes.startSchedulingPage,
        page: StartSchedulingPage.new,
      ),
      generatePage(
        name: Routes.startTheShift,
        page: StartTheShiftPage.new,
      ),
      generatePage(
        name: Routes.statisticalAnalysisPage,
        page: StatisticalAnalysisPage.new,
      ),
      generatePage(
        name: Routes.onOfflineDevice,
        page: OnOfflineDevicePage.new,
      ),
      generatePage(
        name: Routes.scheduleConfigSelectionPage,
        page: ScheduleConfigSelectionPage.new,
      ),
      generatePage(
        name: Routes.systemUserPeopleSelectionSelectionPage,
        page: SystemUserPeopleSelectionSelectionPage.new,
      ),
         generatePage(
        name: Routes.yjsystemuserpeopleselectionselectionpage,
        page: YJSystemUserPeopleSelectionSelectionPage.new,
      ),
      generatePage(
        name: Routes.personnelDepartmentTreePage,
        page: PersonnelDepartmentTreePage.new,
      ),
      generatePage(
        name: Routes.riskCommitment,
        page: RiskCommitmentPage.new,
      ),
       generatePage(
        name: Routes.indexRating,
        page: IndexRatingPage.new,
      ),
       generatePage(
        name: Routes.personnelMonitoringDetails,
        page: DetailPage.new,
      ),
        generatePage(
        name: Routes.todayPage,
        page: TodayPage.new,
      ),
            generatePage(
        name: Routes.maintenancePage,
        page: MaintenancePage.new,
      ),
    ];
  }

  /// 个人页面
  static List<GetPage> _generatePersonalRoutes() {
    return [
      generatePage(
        name: Routes.personalPermission,
        page: PermissionPage.new,
      ),
      generatePage(
        name: Routes.myInfo,
        page: UserInfoPage.new,
      ),
      generatePage(
        name: Routes.myInfoCommon,
        page: CommonPage.new,
      ),
      generatePage(
        name: Routes.personalVersionInfo,
        page: VersionUpdatePage.new,
      ),
      generatePage(
        name: Routes.settingPassword,
        page: SettingPasswordPage.new,
      ),
      generatePage(
        name: Routes.personalHelp,
        page: HelpPage.new,
      ),
      generatePage(
        name: Routes.personalSetting,
        page: SettingListPage.new,
      ),
      generatePage(
        name: Routes.personalScanLogin,
        page: ScanLoginPage.new,
      ),
    ];
  }

  /// 一企一档
  static List<GetPage> _generateOneEnterpriseOneFileRoutes() {
    return [
      generatePage(
        name: Routes.oneEnterpriseOneFile,
        page: OneEnterprise.new,
      ),
    ];
  }
}
